home *** CD-ROM | disk | FTP | other *** search
/ Aminet 45 / Aminet 45 (2001)(GTI - Schatztruhe)[!][Oct 2001].iso / Aminet / game / role / ldmud-3.2-bin.lha / mud / doc / efun / assoc < prev    next >
Text File  |  2001-04-06  |  1KB  |  43 lines

  1. OPTIONAL
  2. SYNOPSIS
  3.         int   assoc (mixed key, mixed *keys)
  4.         mixed assoc (mixed key, mixed *alist [, mixed fail] )
  5.         mixed assoc (mixed key, mixed *keys, mixed *data [, mixed fail] )
  6.  
  7. DESCRIPTION
  8.         All invocation forms search for a <key> in an <alist> (an array
  9.         of two equal-sized arrays) or in an ordered array <keys>.
  10.         An attempt to search in any other structure will yield an
  11.         unpredictable result.
  12.  
  13.         Complexity: O( lg(n) ) , where n is the number of keys.
  14.  
  15.  
  16.         1. Form: Key Search
  17.  
  18.           <key> is searched in the array <keys>, result is the index at
  19.           which <key> was found. If it isn't found, -1 is returned.
  20.  
  21.  
  22.         2. Form: Alist Lookup
  23.  
  24.           <key> is searched in the <alist>, result is the data associated
  25.           with <key> if it is found. If it isn't found, the result
  26.           will be 0, or <fail> if specified.
  27.  
  28.  
  29.         3. Form: Ordered List Lookup
  30.  
  31.           <key> is searched in the array <keys>, the index at which it
  32.           is found is as index into <data> to get the return value.
  33.           If <key> is not found, the reuslt will be 0, or <fail> if
  34.           specified.
  35.  
  36.           For this to be useful, <data> has to be ordered so that
  37.           it matches <key>. This form of lookup is therefore used
  38.           primarily with multidimensional alists.
  39.  
  40. SEE ALSO
  41.         alists(LPC), insert_alist(E), order_alist(E)
  42.  
  43.